package com.logistics.product.controller;

import com.logistics.delivery.entity.model.DeliverySave;
import com.logistics.product.service.CallMaterialService;
import com.logistics.utils.aspect.annotation.LoggerListener;
import com.logistics.utils.constants.LoggerMethod;
import com.logistics.utils.response.ResponseUtil;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

@Controller
@RequestMapping("/lgs/call/material")
public class CallMaterialController {

    @Resource
    CallMaterialService callMaterialService;

    /**
     * 查找拣配单列表
     * @param code
     * @return
     * @throws Exception
     */
    @GetMapping("/picks/{code}")
    @LoggerListener(businessName = "生产叫料-查找拣配单列表", methodName = LoggerMethod.SEARCH)
    public ResponseEntity picks(@PathVariable("code") String code) throws Exception {
        return ResponseUtil.success(callMaterialService.picks(code));
    }

    /**
     * 清单查看明细
     */
    @GetMapping("/detail/{pickId}/{container}")
    @LoggerListener(businessName = "生产叫料-清单查看明细", methodName = LoggerMethod.SAVE)
    public ResponseEntity detail(@PathVariable("pickId") String pickId,@PathVariable("container") String container) throws Exception {
        return ResponseUtil.success(callMaterialService.detail(pickId, container));
    }

    /**
     * 创建配送单
     */
    @PostMapping("/createDelivery")
    @LoggerListener(businessName = "生产叫料-创建配送单", methodName = LoggerMethod.SAVE)
    public ResponseEntity createDelivery(@RequestBody DeliverySave deliverySave) throws Exception {
        return ResponseUtil.success(callMaterialService.createDelivery(deliverySave));
    }

}